# 用于展示训练过程

import matplotlib.pyplot as plt
def load_list(file_name):
    file = open(file_name, 'r')
    list = []
    while 1:
        line = file.readline().strip('\n')
        if not line:
            break
        list.append(eval(line))

    file.close()
    return list
def save_list(file_name, to_save):
    file = open(file_name, 'a')
    for item in to_save:
        file.write(str(item))
        file.write('\n')
    file.close()
train_losses_list = []
test_acc_list = []
train_losses_list = load_list('loss.txt')
test_acc_list = load_list('acc.txt')



# # 解决中文显示问题
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# plt.subplot(1,2,1)
plt.plot(train_losses_list[50000:50100])
plt.xlabel('step')
plt.ylabel('loss')
plt.title('损失折线图')


# plt.subplot(1,2,2)
# plt.plot(test_acc_list[59800:60100])
# plt.xlabel('step')
# plt.ylabel('准确率')
# plt.title('准确率折线图')

plt.show()

